package cn.zzu.Etrip.hometrip.activity;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.administrator.etrip.R;

import java.text.SimpleDateFormat;
import java.util.Date;

import cn.zzu.Etrip.oneday.activity.oneday_database;
import cn.zzu.Etrip.oneday.activity.oneday_pay;
import cn.zzu.Etrip.twoday.activity.TwoDayPayActivity;

public class HomeTripPayActivity extends AppCompatActivity {

    private Button pay_btn;
    private TextView textnaem;
    private TextView title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.familytrip_pay);
        Intent intent = getIntent();
        textnaem = findViewById(R.id.name_p);
        title = findViewById(R.id.name_p2);
        textnaem.setText(intent.getStringExtra("city1") == null ?
                intent.getStringExtra("目的地") :
                intent.getStringExtra("city1"));
        title.setText(intent.getStringExtra("desc1") == null ?
                (intent.getStringExtra("city") + "大学旁独栋豪华大套房") :
                (intent.getStringExtra("desc1")));


        int id = intent.getExtras().getInt("photo");
        final String price = intent.getStringExtra("price1");
        final String desc = intent.getStringExtra("desc1");
        final String city = intent.getStringExtra("city1");

        pay_btn = findViewById(R.id.pay_btn);
        pay_btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                AlertDialog.Builder pay = new AlertDialog.Builder(HomeTripPayActivity.this);
                pay.setTitle("确认订购？");
                pay.setMessage("立即订购!");
                pay.setIcon(R.mipmap.a);
                pay.setNegativeButton("关闭",
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        });
                pay.setPositiveButton("确定",

                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                android.app.AlertDialog.Builder finalResult = new android.app.AlertDialog.Builder(HomeTripPayActivity.this);
                                finalResult.setMessage("订购成功！");
                                finalResult.setPositiveButton("关闭", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        Intent intent = new Intent(HomeTripPayActivity.this, Hometrip_database.class);

                                        intent.putExtra("目的地", city);
                                        intent.putExtra("price", price);
                                        intent.putExtra("desc", desc);
                                        startActivity(intent);
                                    }
                                });
                                finalResult.create();
                                finalResult.show();
                            }
                        });
                pay.show();
            }
        });
    }
}
